# create pickups
(class Pickup (group

	(def dd_sprite sprite)
	(def int counter 0)

	(def dd_sprite player)

	(def int paddingX 0)
	(def int paddingY 0)

	# create pick-up
	(function init (group) (group
		(= this.sprite (new dd_sprite "images/dd_logo.png"))
		(this.sprite.setWidth 50)
		(this.sprite.setHeight 50)
		(this.sprite.setX (/ eng.width 2))
		(this.sprite.setY 50)
		(this.sprite.setVisible 0)
	))

	(function update (group) (group

		# counter to reveal pickup
		(if (== (this.sprite.getVisible) 0)
			(group
			(= this.counter (+ this.counter 1))
			(if (>= this.counter 100)
				(group
				(this.sprite.setX
					(-
						(+ this.paddingX (dd_math.rand (- eng.width  (* this.paddingX 2))))
						(/ (this.sprite.getWidth) 2)
					)
				)
				(this.sprite.setY
					(-
						(+ this.paddingY (dd_math.rand (- eng.height (* this.paddingY 2))))
						(/ (this.sprite.getHeight 2))
					)
				)
				(this.sprite.setVisible 1)
				(= this.counter 0)
				)
			)
			)
		)

		# calculate collision with player
		(if (&& (this.sprite.getVisible) (this.sprite.collidesWith this.player))
			(group
				(this.sprite.setVisible 0)
				(= this.counter 0)
			)
		)
	))

))
